import { Model, AppEvent } from "../../framework/framework";
import { FormatDateTime } from "../../framework/common";
import { ReptileLogic } from "../logics/logic";

class ReptileModel extends Model implements IModel {

    constructor(metiator: IMediator) {
        super(metiator);
    }

    public initialize() {
        this.subscribeToEvents([
            new AppEvent("app.model.reptile.article_list", null, (e, args) => { this.article_list(args); })
        ]);
    }

    public dispose() {
        this.unsubscribeToEvents();
    }

    private article_list(args: number[]): void {
        let lgc = new ReptileLogic();
        lgc.getArticleList({ pageIndex: args[0], pageSize: args[1] }, (list) => {
            this.triggerEvent(new AppEvent("app.view.reptile.article_list", list, null));
        });
    }
}

export { ReptileModel };
